<template>
	<view>
		<ul>
			<li v-for="(item,i) in list" :key="item.id" @click='tz(item.id)'>
				<view class="">
					<u-icon name="close-circle-fill" color="#FF6600" size="20" @tap.stop="del(item.id)"></u-icon>
				</view>
				<view class="jb">
					<text>{{item.username}}</text><text>{{item.userphone}}</text><text v-show="item.status">默认</text>
				</view>
				<view class="dz">
					<view class="">
						{{item.useraddress}}
					</view>
					<view class="">
						<u-icon name="edit-pen-fill" size="30" @tap.stop='bj(i)'></u-icon>
					</view>
				</view>
			</li>

		</ul>
		<button @click="xin">+ 新建收货地址</button>
	</view>
</template>

<script>
	import {
		addreSsremove,
		addreSslist
	} from '@/reuqust/api.js'
	export default {
		data() {
			return {
				list: []
			}
		},
		onShow() {
			addreSslist({
				uid: uni.getStorageSync('userinfo').uid
			}).then(res => {
				console.log(res, 'ddd');
				if (res.data.code == 200) {
					this.list = res.data.list
				}
			})
		},
		methods: {
			xin() {
				uni.navigateTo({
					url: '../addAddress/addAddress'
				})
			},
			del(i) {
				addreSsremove({
					id: i
				}).then(res => {
					console.log(res, '删除');
					if (res.data.code == 200) {
						uni.showToast({
							title: '删除成功'
						})
					}
				})
				addreSslist({
					uid: uni.getStorageSync('userinfo').uid
				}).then(res => {
					console.log(res, 'ddd');
					if (res.data.code == 200) {
						this.list = res.data.list
					}
				})
			},
			tz(i) {
				uni.navigateTo({
					url: '../order/order?id=' + i
				})
			},
			bj(i) {
				// uni.setStorageSync('bj',this.list)
				let site = this.list[i]
				console.log(site, '222222');
				uni.navigateTo({
					url: '../addAddress/addAddress?siteData=' + JSON.stringify(site)
				})
			}
		},

	}
</script>

<style>
	li {
		padding: 20rpx;
	}

	.jb {
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}

	.jb text:nth-child(2) {
		margin-left: 30rpx;
		margin-right: 30rpx;
	}

	.jb text:nth-child(3) {
		background: red;
		color: white;
	}

	.dz {
		display: flex;
		justify-content: space-between;
	}

	button {
		margin-left: 30rpx;
		width: 700rpx;
		background: red;
		color: white;
		border-radius: 50rpx;
		position: fixed;
		bottom: 40rpx;
		height: 100rpx;
		line-height: 100rpx;
	}
</style>
